﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

/// <summary>
/// Summary description for ListMaster
/// </summary>
public class ListMaster : System.Web.UI.MasterPage
{
    protected Pager pgList;
    protected Order odList;
    protected HtmlInputControl tbLayout;
    protected HtmlGenericControl spanLR;
    protected HtmlGenericControl spanUD;
    protected HtmlGenericControl spanSimple;
    protected HtmlTableCell tdAdvancedSearchKey;
    protected ContentPlaceHolder AdvancedSearchPlaceHolder;
    protected HtmlTableCell TdForScroll;

    public Pager Pager
    {
        get
        {
            return this.pgList;
        }
    }

    public Order Order
    {
        get
        {
            return this.odList;
        }
    }

    public string DefaultLayout
    {
        get
        {
            if (ViewState["DefaultLayout"] == null)
                ViewState["DefaultLayout"] = LayoutCode.LR.ToString();
            return ViewState["DefaultLayout"].ToString();
        }
        set
        {
            ViewState["DefaultLayout"] = value;
        }
    }

    public bool ShowPager
    {
        get
        {
            if (ViewState["ShowPager"] == null)
                ViewState["ShowPager"] = true;
            return (bool)ViewState["ShowPager"];
        }
        set
        {
            ViewState["ShowPager"] = value;
        }
    }

    public bool ShowLRLayoutButton
    {
        get
        {
            if (ViewState["ShowLRLayoutButton"] == null)
                ViewState["ShowLRLayoutButton"] = true;
            return (bool)ViewState["ShowLRLayoutButton"];
        }
        set
        {
            ViewState["ShowLRLayoutButton"] = value;
        }
    }

    public bool ShowUDLayoutButton
    {
        get
        {
            if (ViewState["ShowUDLayoutButton"] == null)
                ViewState["ShowUDLayoutButton"] = true;
            return (bool)ViewState["ShowUDLayoutButton"];
        }
        set
        {
            ViewState["ShowUDLayoutButton"] = value;
        }
    }

    public bool ShowSimpleLayoutButton
    {
        get
        {
            if (ViewState["ShowSimpleLayoutButton"] == null)
                ViewState["ShowSimpleLayoutButton"] = true;
            return (bool)ViewState["ShowSimpleLayoutButton"];
        }
        set
        {
            ViewState["ShowSimpleLayoutButton"] = value;
        }
    }

    public bool ShowAdvancedSearch
    {
        get
        {
            if (ViewState["ShowAdvancedSearch"] == null)
                ViewState["ShowAdvancedSearch"] = true;
            return (bool)ViewState["ShowAdvancedSearch"];
        }
        set
        {
            ViewState["ShowAdvancedSearch"] = value;
        }
    }

    public bool ShowScrollDiv
    {
        get
        {
            if (ViewState["ShowScrollDiv"] == null)
                ViewState["ShowScrollDiv"] = true;
            return (bool)ViewState["ShowScrollDiv"];
        }
        set
        {
            ViewState["ShowScrollDiv"] = value;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!ShowPager)
            pgList.Visible = false;

        if (!ShowLRLayoutButton)
            spanLR.Visible = false;

        if (!ShowUDLayoutButton)
            spanUD.Visible = false;

        if (!ShowSimpleLayoutButton)
            spanSimple.Visible = false;

        if (!ShowAdvancedSearch)
            tdAdvancedSearchKey.Style.Add("display", "none");


        if (!ShowScrollDiv)
            TdForScroll.Visible = false;

        if (!IsPostBack)
        {
            tbLayout.Value = DefaultLayout;
        }

        Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "script", "<script language='javascript'>SwitchDefaultTableRow();</script>");

    }
}
